/********************************************************
 * Filename: TclDocumentProvider.java
 * Author: LMU
 * Program: TUnit
 * Description: The document provider for the tcl editor.  
 * Revision History:
 * 20060427: Initial Revision.
 * *****************************************************/

package edu.lmu.cs.tUnit.editor;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.rules.FastPartitioner;
import org.eclipse.ui.editors.text.FileDocumentProvider;

public class TclDocumentProvider extends FileDocumentProvider {
	private TclStringScanner scanner;
	
	protected void setTclStringScanner(TclStringScanner stringScanner) {
		scanner = stringScanner;
	}

	protected IDocument createDocument(Object element) throws CoreException {
		IDocument document = super.createDocument(element);
		if (document != null) {
			IDocumentPartitioner partitioner = new FastPartitioner(scanner, 
					new String[] {TclStringScanner.TCL_STRING});
			partitioner.connect(document);
			document.setDocumentPartitioner(partitioner);
		}
		return document;
	}
}
